package com.xhf.log;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class LoggerInitTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        File file = new File("D:\\workCode\\sca\\xhf-sca-engine\\scaappcheckprovider\\target\\scanner.jar");
        URL url = null;
        try {
            url = file.toURI().toURL();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
        Class<?> aClass = urlClassLoader.loadClass("cn.xhf.cli.CliStartup");
        Class<?> logger = urlClassLoader.loadClass("org.slf4j.impl.StaticLoggerBinder");
        Object o = aClass.newInstance();
        Method start = aClass.getDeclaredMethod("start", new Class[]{String.class});
        start.invoke(o, "{\"appName\":\"test2022102902-02\",\"cliMode\":\"collectFeature\",\"collectOut\":\"/data/jenkinswork/workspace/SCA--JAVA-TEST1\",\"dataPartition\":false,\"dataTotalMode\":true,\"dockerExtractType\":\"docker\",\"esIp\":\"10.0.1.128,10.0.1.131,10.0.1.133,10.0.1.137,10.0.1.138,10.0.1.139:9200\",\"filePath\":\"/data/jenkinswork/workspace/SCA--JAVA-TEST1\",\"folder\":false,\"mergeMode\":\"FULL\",\"nexusRepositories\":[],\"onCache\":false,\"packageType\":\"normal\",\"parseFrom\":2,\"phase\":\"Phase_1\",\"portalIp\":\"10.0.1.127:8080\",\"projectName\":\"test2022102902\",\"pythonMirroring\":[],\"pythonProject\":false,\"retrunCheckReport\":false,\"scanMode\":\"normal\",\"workspacePath\":\"/data/jenkinswork/workspace/SCA--JAVA-TEST1\"}");
//        start.invoke(o);
    }
}
